package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CcsCheckinRecord;
import com.ruoyi.system.service.ICcsCheckinRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 签到记录管理Controller
 * 
 * @author ruoyi
 * @date 2024-04-21
 */
@RestController
@RequestMapping("/system/checkin_record")
public class CcsCheckinRecordController extends BaseController
{
    @Autowired
    private ICcsCheckinRecordService ccsCheckinRecordService;

    /**
     * 查询签到记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsCheckinRecord ccsCheckinRecord)
    {
        startPage();
        List<CcsCheckinRecord> list = ccsCheckinRecordService.selectCcsCheckinRecordList(ccsCheckinRecord);
        return getDataTable(list);
    }

    /**
     * 导出签到记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:export')")
    @Log(title = "签到记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsCheckinRecord ccsCheckinRecord)
    {
        List<CcsCheckinRecord> list = ccsCheckinRecordService.selectCcsCheckinRecordList(ccsCheckinRecord);
        ExcelUtil<CcsCheckinRecord> util = new ExcelUtil<CcsCheckinRecord>(CcsCheckinRecord.class);
        util.exportExcel(response, list, "签到记录管理数据");
    }

    /**
     * 获取签到记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:query')")
    @GetMapping(value = "/{checkinNum}")
    public AjaxResult getInfo(@PathVariable("checkinNum") Long checkinNum)
    {
        return success(ccsCheckinRecordService.selectCcsCheckinRecordByCheckinNum(checkinNum));
    }

    /**
     * 新增签到记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:add')")
    @Log(title = "签到记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsCheckinRecord ccsCheckinRecord)
    {
        return toAjax(ccsCheckinRecordService.insertCcsCheckinRecord(ccsCheckinRecord));
    }

    /**
     * 修改签到记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:edit')")
    @Log(title = "签到记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsCheckinRecord ccsCheckinRecord)
    {
        return toAjax(ccsCheckinRecordService.updateCcsCheckinRecord(ccsCheckinRecord));
    }

    /**
     * 删除签到记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:checkin_record:remove')")
    @Log(title = "签到记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkinNums}")
    public AjaxResult remove(@PathVariable Long[] checkinNums)
    {
        return toAjax(ccsCheckinRecordService.deleteCcsCheckinRecordByCheckinNums(checkinNums));
    }
}
